<?php
if(isset($_GET['gr'])){
    $idgroup = $_GET['gr'];
}else{
    exit(0);
}
if(isset($_GET['ac'])){
    $idaction = $_GET['ac'];
}else{
    exit(0);
}

$rules = $Bus->Rule->select(array(
    'fields'=> array(),
    'where' => "groups_idgroups='{$idgroup}' AND actions_idactions='{$idaction}'"
));
if(count($rules) > 0){
    if($rules[0]->rules_allow == 1){
        $rules[0]->rules_allow = 0;
        $Bus->Rule->update($rules[0], "groups_idgroups='{$idgroup}' AND actions_idactions='{$idaction}'");
    }else{
        $rules[0]->rules_allow = 1;
        $Bus->Rule->update($rules[0], "groups_idgroups='{$idgroup}' AND actions_idactions='{$idaction}'");
    }
    echo $rules[0]->rules_allow;
}
?>